<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title></title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
	href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
	integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
	crossorigin="anonymous">

<!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
<link rel="stylesheet"
	href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
	integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
	crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script
	src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"
	integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
	crossorigin="anonymous"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script type="text/javascript">
	$(function(){
			$.ajax({
				url : "${pageContext.request.contextPath}/supplier/findsupplier.action",
				type : "POST",
				dataType : "json", 
				data : {
				},
				success : function(result, start, resp) {
				var str = "<tr><td>供应商</td><td>地址</td><td>联系人</td><td>电话</td><td>送货方式</td><td>操作</td></tr>";
				for(var i=0;i<result.length;i++){
					var shan= '<a href="${pageContext.request.contextPath}/supplier/delsupplier.action?id='+result[i].uuid+'"><i class="icon-remove"></i></a>';
					var xiu= '<a href="${pageContext.request.contextPath}/supplier/findsupplierId.action?id='+result[i].uuid+'"><i class="icon-pencil"></i></a>';
					if(result[i].needs == 1){
						var needs= "送货";
					}else{
						var needs= "自提";
					}
				    	str += "<tr><td>"
						+result[i].name+"</td><td>"
						+result[i].address+"</td><td>"
						+result[i].contact+"</td><td>"
						+result[i].tele+"</td><td>"
						+needs+"</td><td>"
						+shan+"  "+xiu+"</td></tr>";
				    } 
				$("#t1").html(str);
			 }
		});
	});
	function test(){
	     var name =$("#name1").val();
		 var contact =$("#InputName2").val(); 
		  var tele =$("#teleid").val(); 
		  var needs =$("#needsid").val(); 
		$.ajax({
				url : "${pageContext.request.contextPath}/supplier/findsupplier.action",
				type : "POST",
				dataType : "json", 
				data : {
				"name":name,
				"contact":contact,
				"tele":tele,
				"needs":needs
				},
				success : function(result, start, resp) {
				var str = "<tr><td>供应商</td><td>地址</td><td>联系人</td><td>电话</td><td>送货方式</td><td>操作</td></tr>";
				var shan= "<input type='button' value='删除'>";
				var xiu= "<input type='button' value='修改' onclick='javascript:location.href='${pageContext.request.contextPath }/'' >";
				for(var i=0;i<result.length;i++){
					if(result[i].needs == 0){
						var needs= "自提";
					}
					if(result[i].needs == 1){
						var needs= "送货";
					}
				    	str += "<tr><td>"
						+result[i].name+"</td><td>"
						+result[i].address+"</td><td>"
						+result[i].contact+"</td><td>"
						+result[i].tele+"</td><td>"
						+needs+"</td><td>"
						+shan+xiu+"</td></tr>";
				    } 
				$("#t1").html(str);
			 }
		});
	}
</script>
</head>
<jsp:include page="/jsp/css.jsp"></jsp:include>
<body>
<!-- top.jsp -->
	<jsp:include page="/jsp/top.jsp"></jsp:include>

	<!-- header.jsp -->
	<jsp:include page="/jsp/header.jsp"></jsp:include>

	<div class="content">
		<!-- left -->
		<jsp:include page="/jsp/left.jsp"></jsp:include>
		<div class="mainbar">

			<!-- Page heading -->
			<jsp:include page="/jsp/topshou.jsp"></jsp:include>

			<!-- Matter -->
			<div class="matter">
				<div class="container">
			<h4><span class="page_title">供应商管理</span></h4>
	<div class="container">
		<form class="form-inline">
			<div class="form-group">
				<label for="exampleInputName2">供应商:</label> 
				<input type="text"
					class="form-control" id="name1" size="18" name="name" value="">
			</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			
			<div class="form-group">
				<label for="exampleInputEmail2">联系人:</label> 
				<input type="text" 
				class="form-control" id="InputName2" size="18" name="contact">
			</div>
			<button type="button" class="btn btn-default" onclick="test()">查询</button><p>
			<div class="form-group">
			<label for="exampleInputName2">电&nbsp;&nbsp;话:</label> <input type="text"
					class="form-control" id="teleid" size="18" name="tele">
			</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<div class="form-group">
				<label for="exampleInputEmail2">提货方式：</label> 
				<select class="kuan" id="needsid">
								<option value="-1">----请-选-择----</option>
								<option value="1">送货</option>
								<option value="0">自提</option>
							</select>
	<input type="button" value="创建" onclick="javascript:location.href='${pageContext.request.contextPath }/jsp/supplier/addsupplier.jsp'" class="btn btn-default">		
			</div>
		 <table  class="table table-bordered" id="t1">
		 
		 </table>
		</form>
	</div>
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script src="js/bootstrap.min.js"></script>
		</div>
			</div>

		</div>

		<!-- Mainbar ends -->
		<div class="clearfix"></div>

	</div>

	<!-- Footer starts -->
	<jsp:include page="/jsp/butter.jsp"></jsp:include>

	<!-- Footer ends -->

	<!-- Scroll to top -->
	<span class="totop"><a href="#"><i class="icon-chevron-up"></i></a></span>
	
	
	<jsp:include page="/jsp/js.jsp"></jsp:include>
</body>
</html>
